package com.iknow.xmpp.smack.avatar;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.jivesoftware.smack.packet.PacketExtension;

public class AvatarMetadataExtension
  implements PacketExtension
{
  private List<Info> mInfos = new LinkedList();

  public void addInfo(Info paramInfo)
  {
    this.mInfos.add(paramInfo);
  }

  public String getElementName()
  {
    return "metadata";
  }

  public List<Info> getInfos()
  {
    return this.mInfos;
  }

  public String getNamespace()
  {
    return "urn:xmpp:avatar:metadata";
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder("<metadata xmlns=\"");
    localStringBuilder.append(getNamespace()).append("\">");
    Iterator localIterator = this.mInfos.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        localStringBuilder.append("</metadata>");
        return localStringBuilder.toString();
      }
      localStringBuilder.append(((Info)localIterator.next()).toXML());
    }
  }

  public static class Info
  {
    private int mBytes;
    private int mHeight;
    private String mId;
    private String mType;
    private String mUrl;
    private int mWidth;

    public Info(String paramString1, String paramString2, int paramInt)
    {
      this.mId = paramString1;
      this.mType = paramString2;
      this.mBytes = paramInt;
    }

    public int getBytes()
    {
      return this.mBytes;
    }

    public int getHeight()
    {
      return this.mHeight;
    }

    public String getId()
    {
      return this.mId;
    }

    public String getType()
    {
      return this.mType;
    }

    public String getUrl()
    {
      return this.mUrl;
    }

    public int getWidth()
    {
      return this.mWidth;
    }

    public void setBytes(int paramInt)
    {
      this.mBytes = paramInt;
    }

    public void setHeight(int paramInt)
    {
      this.mHeight = paramInt;
    }

    public void setId(String paramString)
    {
      this.mId = paramString;
    }

    public void setType(String paramString)
    {
      this.mType = paramString;
    }

    public void setUrl(String paramString)
    {
      this.mUrl = paramString;
    }

    public void setWidth(int paramInt)
    {
      this.mWidth = paramInt;
    }

    public String toXML()
    {
      StringBuilder localStringBuilder = new StringBuilder("<info ");
      localStringBuilder.append("id=\"" + this.mId + "\"");
      localStringBuilder.append(" type=\"" + this.mType + "\"");
      localStringBuilder.append(" bytes=\"" + this.mBytes + "\"");
      if (this.mHeight > 0)
        localStringBuilder.append(" height=\"" + this.mHeight + "\"");
      if (this.mWidth > 0)
        localStringBuilder.append(" width=\"" + this.mWidth + "\"");
      if (this.mUrl != null)
        localStringBuilder.append(" url=\"" + this.mUrl + "\"");
      localStringBuilder.append(" />");
      return localStringBuilder.toString();
    }
  }
}